<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <div class="demoTable layui-form" >

            缴费状态：
            <div class="layui-inline" >
                <select name="status" id="status">
                   <option value="">请选择</option>
                    <option value="1">已缴费</option>
                    <option value="0">未缴费</option>
                </select>
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
        </div>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">

            {{# if(d.status=='0' ){ }}
            <a class="layui-btn layui-btn-xs layui-btn-normal data-count-delete" lay-event="goPay">前往缴费</a>
            {{# } }}



        </script>


    </div>
</div>

<script>
    layui.use(['form', 'table','miniPage','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            miniPage = layui.miniPage;

        form.render('select');


        table.render({
            elem: '#currentTableId',
            url: 'carcharge/queryCarchargeAll2',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', width: 100, title: 'ID', sort: true},
                {templet:'<div>{{d.parking.numbers}}</div>',width: 150, title: '车位号码'},
                {templet:'<div>{{d.owner.username}}</div>',width: 150, title: '户主'},

                {field: 'payDate', width: 150, title: '开始时间'},
                {field: 'endDate', width: 150, title: '结束时间'},
                {field: 'money', width: 120, title: '金额'},
                {field: 'status', width: 300, title: '状态',
                 templet: function(res){
                    if(res.status=='0'){
                        return '<span class="layui-badge layui-bg-red" >要缴费了...</span>';
                    }else{
                        return '<span class="layui-badge layui-bg-green" >已缴费</span>';
                    }
                 }
                },
                {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            // skin: 'line',
            id: 'testReload'
        });


        var $ = layui.$, active = {
            reload: function(){

                var status = $('#status');
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {

                        status:status.val()
                    }
                }, 'data');
            }
        };

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'goPay') {
                layer.confirm('确定要前往缴费吗？', function (index) {
                    // console.log(data.id)

                    window.location.href = payUrl+"/payment/goPay?id=" + data.id
                });


            } else if (obj.event === 'urgingPayment') {

            } else if (obj.event === 'delete') {
                layer.confirm('真的删除行么', function (index) {
                    deleteByIds($,"repair/deleteByIds",data.id,index)
                });
            }
            else if (obj.event === 'choose') {
                var content = miniPage.getHrefContent('page/business/repair/chooseRepairPersonnel.html');
                var index = openPage(content,"选择维修人员",'70%','70%');
                var data = obj.data;
                //渲染数据
                setFormValues(data);
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false
            }
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });
</script>